//
//  QGAsyncImageView.h
//  qeegooChat
//
//  Created by heew on 16/1/7.
//  Copyright © 2016年 com.autozi. All rights reserved.
//

#import <UIKit/UIKit.h>
@class QGAsyncImageView;

typedef void (^GJCUAsyncImageViewDownloadTaskProgressBlock) (QGAsyncImageView *imageView,CGFloat progress);

typedef void (^GJCUAsyncImageViewDownloadTaskCompletionBlock) (QGAsyncImageView *imageView,BOOL completion);

@interface QGAsyncImageView : UIImageView

/**
 *  需要缓存的目标路径，如果没有设置，就启用默认缓存目录路径
 */
@property (nonatomic,strong)NSString *cachePath;

/**
 *  图片地址链接
 */
@property (nonatomic,strong)NSString *url;

/**
 *  图片下载进度
 */
@property (nonatomic,readonly)CGFloat downloadProgress;

/**
 *  任务唯一标示
 */
@property (nonatomic,readonly)NSString *downloadTaskUniqueIdentifier;

/**
 *  转圈
 */
@property (nonatomic,strong)UIActivityIndicatorView *indicatorView;

/**
 *  是否显示转圈
 */
@property (nonatomic,assign)BOOL showDownloadIndicator;

/**
 *  是否在对象被销毁的时候取消下载任务，默认为NO
 */
@property (nonatomic,assign)BOOL isAutoCancel;

/**
 *  从缓存路径读取出的图片
 */
@property (nonatomic,readonly)UIImage *cachedImage;

/**
 *  组下载任务标示
 */
@property (nonatomic,strong)NSString *groupDownloadTaskIdentifier;

/**
 *  观察下载任务完成
 *
 *  @param completionBlock 观察者
 */
- (void)configDownloadTaskProgressBlock:(GJCUAsyncImageViewDownloadTaskProgressBlock)progressBlock;

/**
 *  观察任务完成
 *
 *  @param completionBlock
 */
- (void)configDownloadTaskCompletionBlock:(GJCUAsyncImageViewDownloadTaskCompletionBlock)completionBlock;

/**
 *  调整转圈位置
 */
- (void)adjustIndicatorPosition;

/**
 *  根据组任务标示来取消下载
 *
 *  @param groupTaskIdentifier
 */
+ (void)cancelGroupDownloadTask:(NSString *)groupTaskIdentifier;


@end
